export default function generateRandomSequence(n, length = 0) {
  if (length <= 0 || length > n) {
    // throw new Error("Length must be a positive integer.");
    length = n;
  }
  const sequence = [];
  for (let i = 0; i < length; i++) {
    const randomNumber = Math.floor(Math.random() * n); // 生成 0 到 n-1 的随机数
    sequence.push(randomNumber);
  }
  return sequence;
}

// // 示例用法
// const n = 10; // 不包含 10
// const length = 5; // 生成的数列长度
// const randomSequence = generateRandomSequence(n, length);
// console.log(randomSequence); // 输出可能是 [3, 7, 1, 4, 9]
